/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kn.cstf2.cop.Shared;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import kn.cstf2.cop.Bean.*;
import kn.cstf2.cop.Server.CopServer;
import kn.cstf2.global.Utils.CstF2Exception;
import kn.cstf2.implementation.Bean.ClienteStkBean;
import kn.cstf2.implementation.Bean.T_asignStkBean;
import kn.cstf2.transition.Bean.TransitionBean;

/**
 *
 * @author user1
 */
public class CopShared {

    CopServer copServer = new CopServer();
    
    public ArrayList<ContactsBean> getContactList(int idCop){
        return copServer.getContactList(idCop);
    }
    
    public void removeContacto(int id){
        copServer.removeContacto(id);
    }

    public CopBean GetDataFromCop(Integer id, Boolean esportacion) {

        CopBean copBean = new CopBean();
        if (copBean != null) {
            copBean = copServer.obtenerDataFromCop(id, esportacion);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return copBean;
    }

    public void InsertDefaultValuesEnCop(Boolean esportacion, Integer id) {
        copServer.insertarValoresDefaultEnCop(esportacion, id);
    }

    public ClienteStkBean GetAllDataFromClientesSTK(Integer knkey) {

        ClienteStkBean clienteStkBean = new ClienteStkBean();
        if (clienteStkBean != null) {
            clienteStkBean = copServer.obtenerTodosDatosFromClientesSTK(knkey);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return clienteStkBean;
    }

    public ClienteStkBean GetAcountVisibilitySTK(Integer knkey) {

        ClienteStkBean clienteStkBean = new ClienteStkBean();
        if (clienteStkBean != null) {
            clienteStkBean = copServer.obtenerAcountVisibilitySTK(knkey);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return clienteStkBean;
    }

//    public ExceptionBean  GetExceptionSTK (Integer idcop){
//    
//    ExceptionBean exceptionBean=new ExceptionBean();
//    if (exceptionBean != null) {        
//            exceptionBean = copServer.obtenerExceptions(idcop);
//        } else {
//            throw new CstF2Exception("El Usuario es null");
//        }
//    return exceptionBean;
//   }  
    public ArrayList<ExceptionBean> GetExceptionListSTK(Integer idcop) {

        ExceptionBean exceptionBean = new ExceptionBean();
        ArrayList<ExceptionBean> exceptionBeanList = new ArrayList<ExceptionBean>();
        if (exceptionBean != null) {
            exceptionBeanList = copServer.obtenerExceptions(idcop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return exceptionBeanList;
    }

    public void InsertExceptionSTK(ExceptionBean exceptioBean, Integer copbeanID) {

        ExceptionBean exceptionBean = new ExceptionBean();
        if (exceptionBean != null) {
            copServer.insertarExceptions(exceptioBean, copbeanID);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void InsertKpisSTK(KpiBean kpiBean, Integer idcop) {

        //KpiBean kpiBean=new KpiBean();
        if (kpiBean != null) {
            copServer.insertarKpis(kpiBean, idcop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public ArrayList<KpiBean> GetKpiSTK(Integer idcop) {

        KpiBean kpiBean = new KpiBean();
        ArrayList<KpiBean> kpiBeanList = new ArrayList<KpiBean>();

        if (kpiBean != null) {
            kpiBeanList = copServer.obtenerKpis(idcop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return kpiBeanList;
    }

    public T_customer_solutionBeanSTK GetCustomerSolutionStk(Integer knkey) {

        T_customer_solutionBeanSTK t_customer_solutionBeanSTK = new T_customer_solutionBeanSTK();

        if (knkey != null) {
            t_customer_solutionBeanSTK = copServer.obtenerCustomerSolutionStk(knkey);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return t_customer_solutionBeanSTK;
    }

    public static Date GetTheDateTime() {
        DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
        Date date = new Date();
        System.out.println(dateFormat.format(date));

        return date;
    }

    public void InsertIntoContats(ContactsBean contactsBean) {

        //ContactsBean contactsBean=new ContactsBean();
        if (contactsBean != null) {
            copServer.insertarEnContats(contactsBean);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        //return clienteStkBean;
    }

    public void UpdateContactsyContacsDateIntoTransitions(TransitionBean transitionBean) {

        //ContactsBean contactsBean=new ContactsBean();
        if (transitionBean != null) {
            copServer.actualizarContactsyContacsDateIntoTransitions(transitionBean);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        //return clienteStkBean;
    }

    public ContactsBean GetDatosDeContacts(Integer idCop) {

        ContactsBean contactsBean = new ContactsBean();
        if (contactsBean != null) {
            copServer.obtenerDatosDeContacts(idCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return contactsBean;
    }

    public void DeleteContacto(Integer idCop) {

        if (idCop != null) {
            copServer.eliminarContacto(idCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }

    }

    public Integer ContarContactosEnTransitions(Integer idTransition) {
        Integer count = 0;
        if (idTransition != null) {
            count = copServer.contarContactosEnTransitions(idTransition);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return count;
    }

    public void DesableContacts(Integer idTransition) {
        Integer count = 0;
        if (idTransition != null) {
            copServer.deshabilitarContactos(idTransition);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        //return count;
    }

    public T_asignStkBean GetIfOwnerFromSTK(Integer knkey) {

        T_asignStkBean t_asignStkBean = new T_asignStkBean();
        if (t_asignStkBean != null) {
            t_asignStkBean = copServer.obtenerIfOwnerFromSTK(knkey);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return t_asignStkBean;
    }

    public void UpdateReportingTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateReportingTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateScopeOfServiceTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateScopeOfServiceTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateConditionTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateConditionTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateCielIdTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateCielIdTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateCielQModuleTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateCielQModuleTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateAconTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateAconTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateCarrierCCTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateCarrierCCTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateWorkingSTTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateWorkingSTTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateSopTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateSopTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateKpiTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateKpiTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateBillingTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateBillingTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateClienteSTK(ClienteStkBean clienteStkBean) {

        if (clienteStkBean != null) {
            copServer.UpdateClienteSTK(clienteStkBean);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateContactsTransition(TransitionsBeanCop transitionsBeanCop) {

        if (transitionsBeanCop != null) {
            copServer.UpdateContactsTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public void UpdateCop(CopBean copBean) {

        if (copBean != null) {
            copServer.UpdateCop(copBean);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
    }

    public TransitionsBeanCop SelectAllDataFromTransition(Integer id) {

        TransitionsBeanCop transitionsBeanCop = new TransitionsBeanCop();
        if (id != null) {
            transitionsBeanCop = copServer.SelectAllDataFromTransition(id);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        return transitionsBeanCop;
    }

    public void UpdateTransition(TransitionsBeanCop transitionsBeanCop) {

        //TransitionsBeanCop transitionsBeanCop = new TransitionsBeanCop();
        if (transitionsBeanCop != null) {
            copServer.UpdateTransition(transitionsBeanCop);
        } else {
            throw new CstF2Exception("El Usuario es null");
        }
        //return transitionsBeanCop;
    }

    public CopBean validarsihaynull(CopBean subproducts, CopBean copBean) {

        if (subproducts.getArrivaltocustoms() == null) {
            subproducts.setArrivaltocustoms(copBean.getArrivaltocustoms());
        }
        if (subproducts.getArrivaltodelivery() == null) {
            subproducts.setArrivaltodelivery(copBean.getArrivaltodelivery());
        }
        if (subproducts.getBlueancorline() == null) {
            subproducts.setBlueancorline(copBean.getBlueancorline());
        }
        if (subproducts.getBrokerage() == null) {
            subproducts.setBrokerage(copBean.getBrokerage());
        }
        if (subproducts.getCustomsclearance() == null) {
            subproducts.setCustomsclearance(copBean.getCustomsclearance());
        }
        if (subproducts.getEscortclient() == null) {
            subproducts.setEscortclient(copBean.getEscortclient());
        }
        if (subproducts.getEscortkn() == null) {
            subproducts.setEscortkn(copBean.getEscortkn());
        }
        if (subproducts.getExport() == null) {
            subproducts.setExport(copBean.getExport());
        }
        if (subproducts.getExportcustoms() == null) {
            subproducts.setExportcustoms(copBean.getExportcustoms());
        }
        if (subproducts.getFcl() == null) {
            subproducts.setFcl(copBean.getFcl());
        }
        if (subproducts.getImportcustoms() == null) {
            subproducts.setImportcustoms(copBean.getImportcustoms());
        }
        if (subproducts.getInbondexp() == null) {
            subproducts.setInbondexp(copBean.getInbondexp());
        }
        if (subproducts.getInbondim() == null) {
            subproducts.setInbondim(copBean.getInbondim());
        }
        if (subproducts.getInsurance() == null) {
            subproducts.setInsurance(copBean.getInsurance());
        }
        if (subproducts.getIntermodal() == null) {
            subproducts.setIntermodal(copBean.getIntermodal());
        }
        if (subproducts.getLcl() == null) {
            subproducts.setLcl(copBean.getLcl());
        }
        if (subproducts.getMaincarriage() == null) {
            subproducts.setMaincarriage(copBean.getMaincarriage());
        }
        if (subproducts.getOceanfreight() == null) {
            subproducts.setOceanfreight(copBean.getOceanfreight());
        }
        if (subproducts.getOnallmotor() == null) {
            subproducts.setOnallmotor(copBean.getOnallmotor());
        }
        if (subproducts.getOncombined() == null) {
            subproducts.setOncombined(copBean.getOncombined());
        }
        if (subproducts.getPerishables() == null) {
            subproducts.setPerishables(copBean.getPerishables());
        }
        if (subproducts.getPickuptosiling() == null) {
            subproducts.setPickuptosiling(copBean.getPickuptosiling());
        }
        if (subproducts.getPreallmotor() == null) {
            subproducts.setPreallmotor(copBean.getPreallmotor());
        }
        if (subproducts.getPrecombined() == null) {
            subproducts.setPrecombined(copBean.getPrecombined());
        }
        if (subproducts.getSeatransport() == null) {
            subproducts.setSeatransport(copBean.getSeatransport());
        }
        if (subproducts.getAttachedfiles() == null) {
            subproducts.setAttachedfiles(copBean.getAttachedfiles());
        }
        if (subproducts.getDestconditions() == null) {
            subproducts.setDestconditions(copBean.getDestconditions());
        }
        if (subproducts.getOriginconditions() == null) {
            subproducts.setOriginconditions(copBean.getOriginconditions());
        }
        if (subproducts.getOverview() == null) {
            subproducts.setOverview(copBean.getOverview());
        }
        if (subproducts.getProtocol() == null) {
            subproducts.setProtocol(copBean.getProtocol());
        }
        if (subproducts.getRequirements() == null) {
            subproducts.setRequirements(copBean.getRequirements());
        }
        if (subproducts.getWorkinst() == null) {
            subproducts.setWorkinst(copBean.getWorkinst());
        }
        if (subproducts.getId() == null) {
            subproducts.setId(copBean.getId());
        }
        if (subproducts.getIdtransitioncop() == null) {
            subproducts.setIdtransitioncop(copBean.getIdtransitioncop());
        }
        return subproducts;
    }
}
